#ifndef SIMULATED_ANNEALING_H
#define SIMULATED_ANNEALING_H 

#include <vector>
#include "./t_tree.h"

class Simulated_Annealing {
public:
	Simulated_Annealing(std::vector<Cube> & cubes) : now_tree_(cubes), best_tree_(cubes) {
		original_volume_ = 0;
		for (int i = 0; i < cubes.size(); i++) original_volume_ += cubes[i].GetVolume();
	}
	~Simulated_Annealing() {}
	// Transform to another status and return the index of the operation 
	virtual int Transform(TTree & tree, std::vector<int> & t) = 0;  
	// get the solution and return the packed cubes
	virtual void GetAns(std::vector<Cube> &cubes);  
protected:
	// Simulated_Annealing algorithm
	void SASolve();
	double initial_possibility_, stop_eps_, temperature_;
	std::vector<double> temperature_drop_velocity_;
	int random_frequency_, original_volume_, transform_times_;
	TTree now_tree_, best_tree_;
};

#endif /* SIMULATED_ANNEALING_H */
